<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
    	body{font-size:14px;color:#666;}
    	a{text-decoration:none;}
    	.clearfix:after{content:".";display:block;clear:both;visibility:hidden;overflow:hidden;height:0;}
    	.clearfix{zoom:1;}
    	.content{margin:20px auto;width:1200px;}
        .box{float:left;position:relative;margin-right:20px;width:390px;height:440px;overflow:hidden;outline:1px solid #afa;}
        .b-head{width:340;padding:0 20px 0 30px;height:55px;color:#fff;background:#76488e;}
        .b-head h3{float:left;margin:0;height:50px;line-height:50px;font-size:26px;font-weight:400;}
        .b-head a{float:right;padding-right:20px;height:55px;line-height:55px;color:#fff;}
        .b-head a span{display:inline-block;margin-left:3px;width:15px;height:16px;background:url(imgs/1/sprite_index@1x.png) -154px -40px no-repeat;vertical-align:middle;}
        .b-content{display:none;width:360px;margin:0 auto;}
        .bc-active{display:block;}
        .b-content .bc-content{padding-top:0;}
		.b-content .bc-line{margin:auto;margin-top:18px;width:330px;height:1px;background:#eee;}
        .bc-sub{text-indent:10px;}
        .b_ind{margin-top:18px;padding:0;text-align:center;font-size:0;}
        .b_ind li{display:inline-block;list-style:none;margin-right:10px;width:8px;height:8px;border-radius:50%;background:#c8c8c8;}
        .b_ind li.bi-active{background:#e01222;}
        .b-btn{position:absolute;top:50%;margin-top:-25px;display:none;width:20px;height:50px;line-height:50px;text-align:center;color:#797173;background:#f3f2f3;z-index:1;}
        .b-btnlt{left:0;}
        .b-btnrt{right:0;}
    </style>
</head>
<body>
	<div class="content clearfix">
	    <div id="box1" class="box">
	    	<div class="b-head .clearfix">
	    		<h3>会买专辑</h3>
	    		<a href="">甄选优质好物<span></span></a>
	    	</div>
	    	<div class="b-content bc-active">
	    		<div class="bc-content">
	    			<a href="#"></a>
	    			<p class="bc-sub">手机追剧不发愁，4千毫安大电池任你看</p>
	    			<img src="imgs/1/5926813bN63c3b193.jpg" alt="">
	    			<img src="imgs/1/599a39f9N346f5b31.jpg" alt="">
	    			<img src="imgs/1/58dbb456N78528740.jpg" alt="">
	    		</div>
	    		<div class="bc-line"></div>
	    		<div class="bc-content">
	    			<a href="#"></a>
	    			<p class="bc-sub">清新森系连衣裙，非你莫属</p>
	    			<img src="imgs/1/58cb8d88Na4d13679.jpg" alt="">
	    			<img src="imgs/1/58a3bdb5N46d1d2af.jpg" alt="">
	    			<img src="imgs/1/58ceb619N150fe2e2.jpg" alt="">
	    		</div>
	    	</div>
	    	<div class="b-content">
	    		<div class="bc-content">
	    			<a href="#"></a>
	    			<p class="bc-sub">家装完毕购家电，一站式汇总更贴心</p>
	    			<img src="imgs/1/59092fbeNb6c2296a.jpg" alt="">
	    			<img src="imgs/1/599aa505N070ee14f.jpg" alt="">
	    			<img src="imgs/1/5979d30fN551b603b.jpg" alt="">
	    		</div>
	    		<div class="bc-line"></div>
	    		<div class="bc-content">
	    			<a href="#"></a>
	    			<p class="bc-sub">运动耳机助燃，嘻哈节奏为健身添动力</p>
	    			<img src="imgs/1/583d1f81N65ef6f61.jpg" alt="">
	    			<img src="imgs/1/58b3eca3N1a9612a3.jpg" alt="">
	    			<img src="imgs/1/58c6610fN8cdf13b8.jpg" alt="">
	    		</div>
	    	</div>
	    	<div class="b-content">
	    		<div class="bc-content">
	    			<a href="#"></a>
	    			<p class="bc-sub">网红直播，离不开这些美颜黑科技</p>
	    			<img src="imgs/1/58a27dbaNf16f9b98.jpg" alt="">
	    			<img src="imgs/1/58130a20Nae916523.jpg" alt="">
	    			<img src="imgs/1/5844f1eaN27e9cb02.jpg" alt="">
	    		</div>
	    		<div class="bc-line"></div>
	    		<div class="bc-content">
	    			<a href="#"></a>
	    			<p class="bc-sub">初心不改，七夕用美味零食回味初恋时的甜蜜</p>
	    			<img src="imgs/1/56f4b679Ndc43c62a.jpg" alt="">
	    			<img src="imgs/1/572961f9N9881f0bb.jpg" alt="">
	    			<img src="imgs/1/59955ae9N2df8a72a.jpg" alt="">
	    		</div>
	    	</div>
	    	<a class="b-btn b-btnlt" href="#"><</a>
	    	<a class="b-btn b-btnrt" href="#">></a>
	    	<ul class="b_ind">
	    		<li class="bi-active"></li>
	    		<li class=""></li>
	    		<li class=""></li>
	    	</ul>
	    </div>
	    <div id="box2" class="box">
	    	<div class="b-head .clearfix">
	    		<h3>会买专辑</h3>
	    		<a href="">甄选优质好物<span></span></a>
	    	</div>
	    	<div class="b-content bc-active">
	    		<div class="bc-content">
	    			<a href="#"></a>
	    			<p class="bc-sub">手机追剧不发愁，4千毫安大电池任你看</p>
	    			<img src="imgs/1/5926813bN63c3b193.jpg" alt="">
	    			<img src="imgs/1/599a39f9N346f5b31.jpg" alt="">
	    			<img src="imgs/1/58dbb456N78528740.jpg" alt="">
	    		</div>
	    		<div class="bc-line"></div>
	    		<div class="bc-content">
	    			<a href="#"></a>
	    			<p class="bc-sub">清新森系连衣裙，非你莫属</p>
	    			<img src="imgs/1/58cb8d88Na4d13679.jpg" alt="">
	    			<img src="imgs/1/58a3bdb5N46d1d2af.jpg" alt="">
	    			<img src="imgs/1/58ceb619N150fe2e2.jpg" alt="">
	    		</div>
	    	</div>
	    	<div class="b-content">
	    		<div class="bc-content">
	    			<a href="#"></a>
	    			<p class="bc-sub">家装完毕购家电，一站式汇总更贴心</p>
	    			<img src="imgs/1/59092fbeNb6c2296a.jpg" alt="">
	    			<img src="imgs/1/599aa505N070ee14f.jpg" alt="">
	    			<img src="imgs/1/5979d30fN551b603b.jpg" alt="">
	    		</div>
	    		<div class="bc-line"></div>
	    		<div class="bc-content">
	    			<a href="#"></a>
	    			<p class="bc-sub">运动耳机助燃，嘻哈节奏为健身添动力</p>
	    			<img src="imgs/1/583d1f81N65ef6f61.jpg" alt="">
	    			<img src="imgs/1/58b3eca3N1a9612a3.jpg" alt="">
	    			<img src="imgs/1/58c6610fN8cdf13b8.jpg" alt="">
	    		</div>
	    	</div>
	    	<div class="b-content">
	    		<div class="bc-content">
	    			<a href="#"></a>
	    			<p class="bc-sub">网红直播，离不开这些美颜黑科技</p>
	    			<img src="imgs/1/58a27dbaNf16f9b98.jpg" alt="">
	    			<img src="imgs/1/58130a20Nae916523.jpg" alt="">
	    			<img src="imgs/1/5844f1eaN27e9cb02.jpg" alt="">
	    		</div>
	    		<div class="bc-line"></div>
	    		<div class="bc-content">
	    			<a href="#"></a>
	    			<p class="bc-sub">初心不改，七夕用美味零食回味初恋时的甜蜜</p>
	    			<img src="imgs/1/56f4b679Ndc43c62a.jpg" alt="">
	    			<img src="imgs/1/572961f9N9881f0bb.jpg" alt="">
	    			<img src="imgs/1/59955ae9N2df8a72a.jpg" alt="">
	    		</div>
	    	</div>
	    	<a class="b-btn b-btnlt" href="#"><</a>
	    	<a class="b-btn b-btnrt" href="#">></a>
	    	<ul class="b_ind">
	    		<li class="bi-active"></li>
	    		<li class=""></li>
	    		<li class=""></li>
	    	</ul>
	    </div>
	</div>
    <script>
    	modelAnimate('box1');
    	modelAnimate('box2');
    	// modelAnimate('box1',{btns:'b-btn2'});
	    function modelAnimate(id,opts) {
	    	// var defaultOpts = {
	    	// 	btns:'b-btn',
	    	// 	subIndexs:'b_ind'
	    	// }
	    	// for (var index in opts){
	    	// 	if (opts[index]){
	    	// 		defaultOpts[i] = opts[index];
	    	// 	}
	    	// }
	    	var box = document.getElementById(id);
	    	var btns = box.getElementsByClassName('b-btn');
	    	var subIndexs = box.getElementsByClassName('b_ind')[0].getElementsByTagName('li');
	    	var bContents = box.getElementsByClassName('b-content');
	    	var i = 0;
	    	var t;
	    	var controler = {
	    		btnDir:'',
	    	} 
	    	function doAnimate(){
	    		if(controler.btnDir == ''){
		    		if(i>=bContents.length){
		    			i=0;
		    		}
		    		Animate(i);
			    	i++;
	    		} else if(controler.btnDir == 'left'){
	    			if(i<=0){
		    			i=bContents.length-1;
		    		} else {
		    			i--;
		    		}
		    		Animate(i);
		    		controler.btnDir = '';
	    		}
	    		function Animate(i){
	    			for (var j = 0,len=subIndexs.length; j < len; j++) {
	    				subIndexs[j].className = '';
	    				bContents[j].style.display = 'none';
	    			}
	    			subIndexs[i].className = 'bi-active';
	    			bContents[i].style.display = 'block';
		    	};
	    	}
	    	t = setInterval(doAnimate,2000);
	    	//下方按钮鼠标事件
	    	for (var i = 0,len=subIndexs.length; i < len; i++) {
	    		(function(i){
		    		subIndexs[i].onmouseover = function () {
		    			clearInterval(t);
		    			for (var j = 0,len=subIndexs.length; j < len; j++) {
		    				subIndexs[j].className = '';
		    				bContents[j].style.display = 'none';
		    			}
		    			this.className = 'bi-active';
		    			bContents[i].style.display = 'block';
		    		}
		    		subIndexs[i].onmouseout = function () {
		    			clearInterval(t);
		    			t = setInterval(doAnimate,2000);
		    		}
	    		}(i));
	    	}
	    	//控制左右侧按钮显示隐藏
	    	box.onmouseover = function(){
	    		clearInterval(t);
	    		for(var i=0,len=btns.length; i<len; i++){
	    			btns[i].style.display = 'block' ;
	    		}
	    	}
	    	box.onmouseout = function(){
	    		clearInterval(t);
	    		t = setInterval(doAnimate,2000);
	    		for(var i=0,len=btns.length; i<len; i++){
	    			btns[i].style.display = 'none' ;
	    		}
	    	}
	    	//左右侧按钮鼠标事件
	    	btns[0].onclick = function(){
	    		controler.btnDir = 'left';
	    		doAnimate();
	    	}
	    	btns[1].onclick = function(){
	    		controler.btnDir = '';
	    		doAnimate();
	    	}
	    }
        
    </script>
</body>
</html>